import request from './apiConfig'
const base_url = '/employees'

/**
 * 员工入职
 * @param {*} emp 
 * @param {*} startDate 实习开始日期
 * @param {*} endDate 实习结束日期
 */
export function insertEmpApi(emp, internshipStartDate, internshipEndDate) {
    return request({
        url: base_url,
        method: 'POST',
        data: emp,
        params: {
            internshipStartDate,
            internshipEndDate
        },
    })
}

export function listEmployeeInfo(query) {
    return request({
        url: base_url,
        method: 'GET',
        params: query,
    })
}
/**
 * 部门调转用员工表
 * @param {*} query 
 */
export function listEmployee(query) {
    return request({
        url: base_url + "/list",
        method: "GET",
        params: query,
    })
}

export function updateEmployee(emp, internshipStartDate, internshipEndDate) {
    return request({
        url: base_url,
        method: 'PUT',
        data: emp,
        params: {
            internshipStartDate,
            internshipEndDate
        },
    })
}


/**
 * 根据公司统计各部门月入职人数
 */
export function statisticsEntryEmpByCompanyApi(pId) {
    return request({
        url: `${base_url}/statistics/${pId}/entry`,
    })
}

export function getEmployeeById(id) {
    return request({
        url: `${base_url}/${id}`,
        method: 'GET'
    })
}
/**
 * 根据id获取调转员工信息
 * @param {*} id 
 */
export function getEmpToDeptLog(id){
    return request({
        url:`${base_url}/deptTranLog/${id}`,
        method:'GET'
    })
}

export function getTalentPool(query) {
    return request({
        url: `${base_url}/talent-pool`,
        method: 'GET',
        params: query
    })
}

export function entryById(id, entry) {
    return request({
        url: `${base_url}/${id}`,
        method: 'PATCH',
        data: entry
    })
}

export function deleteTalent(id) {
    return request({
        url: `${base_url}/talent/${id}`,
        method: 'PATCH',
    })
}

export function getInternshipData() {
    return request({
        url: `${base_url}/internship/month/data`,
        method: "GET"
    })
}

export function getEntryDataByPid(pId){
    return request({
        url:`${base_url}/data/${pId}`,
        method:"GET"
    })
}